package info.techgeek.labs.regex.urlsplitter;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SVNTagGetter {

	public static void main(String[] args) {
		
		String svnUrls =  "https://svn.bansel.it/h2o/AperturaContieDepositi/tags/PP_81_200707051502/";
		
		SVNTagGetter svnTagGetter = new SVNTagGetter();
		svnTagGetter.getTagName(svnUrls);
		
	}
	
	private String getTagName(String query)
	{
		Pattern p = Pattern.compile("/[a-z0-9_\\-A-Z]+");
		Matcher m = p.matcher(query);
		List<String> aList = new ArrayList<String>(); 
		String str ;
		while (m.find())
		{
			str = m.group();
			str = str.substring(1);
			if(!aList.contains(str)){
				System.out.println(" str "+str);
				aList.add(str);
			}
		}
		int listSize  = aList.size();
		System.out.println(" alist "+aList);
		System.out.println(" alist Size "+ listSize);
		
		String tagName = aList.get(listSize-1);
		
		System.out.println(" tagName "+ tagName);
		
		return tagName;
	}
	
}
